﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TowerTerrainChange : MonoBehaviour {
    public GameObject terrainObejct;
    public VRControllerInteractive VRInteractive;
    public Tower tower;

    public bool Test_ToSwitch;



    private void Awake()
    {
        VRInteractive.StartHolding += SwitchTerrainObject;
    }

    private void Update()
    {
        if(Test_ToSwitch)
        {
            Test_ToSwitch = false;
            SwitchTerrainObject();
        }
    }

    public void SwitchTerrainObject()
    {
        if (tower.TowerOwner == PlayerType.Player)
        {
            terrainObejct.SetActive(!terrainObejct.activeInHierarchy);
            LocalNavMeshBuilder.Instance.RebuildNavMesh();
        }
        
    }
}
